<template>
  <h2>watch-setup属性</h2>
  <span>{{ count }}</span>
  <button @click="add">+</button>
</template>

<script setup>
import { ref, watch } from "vue";

const count = ref(1);
const add = () => {
  count.value++;
};

const unWatch = watch(
  count,
  (val, oldVal) => {
    console.log(val, oldVal);
  },
  {
    immediate: true,
    deep: true,
    flush: "post",
  }
);
</script>
